﻿using Fluffy.WinForms;
using System.Windows;
using System.Windows.Media;

namespace Fluffy.Library.Utils
{
    public static class UiUtils
    {
        public static T GetParent<T>(FrameworkElement child) where T : FrameworkElement
        {
            while (child != null && !(child is T))
            {
                child = child.Parent as FrameworkElement;
            }

            return child as T;
        }

	    public static ImageSource GetFileIcon(string path, bool isLarge)
	    {
			return IconReader.GetFileIcon(path, isLarge ? IconReader.IconSize.Large : IconReader.IconSize.Small, false);
	    }

		public static ImageSource GetDirectoryIcon(bool isLarge, bool isOpen)
	    {
			return IconReader.GetFolderIcon(isLarge ? IconReader.IconSize.Large : IconReader.IconSize.Small, isOpen ? IconReader.FolderType.Open : IconReader.FolderType.Closed);
	    }
    }
}
